<template>
  <page-card title="消息中心"
             :need-back="true">
    <div>
      <msg-text v-if="msgInfo.contentType == 'text'"
                :msgInfo="msgInfo"></msg-text>
      <msg-link v-if="msgInfo.contentType == 'link'"
                :msgInfo="msgInfo"></msg-link>
      <msg-action-card v-if="msgInfo.contentType == 'action_card'"
                       :msgInfo="msgInfo"></msg-action-card>
    </div>
  </page-card>
</template>

<script>
import msgText from './Text'
import msgLink from './Link'
import msgActionCard from './ActionCard'
import { getMessageInfoById, updateReadStatusOne } from '../../api/message/index'
export default {
  components: { msgText, msgLink, msgActionCard },
  data () {
    return {
      msgId: '',
      insideMsgId: '',
      msgInfo: {}
    }
  },
  created () { },
  mounted () {
    this.msgId = this.$route.query.msgId
    this.insideMsgId = this.$route.query.insideMsgId
    this.getId()
    this.readMsg()
  },
  methods: {
    getId () {
      getMessageInfoById(this.msgId).then((response) => {
        this.msgInfo = response
      })
    },
    readMsg () {
      updateReadStatusOne(this.insideMsgId).then((response) => { })
    }
  }
}
</script>

<style lang="less">
</style>
